﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Charisma.Tests
{
    public static class RepositoryConfiguratorExtensions
    {
        private static FieldInfo member;
        private static FieldInfo memberName;
        private static FieldInfo name;

        public static MemberInfo GetMember(this RepositoryConfigurator configurator)
        {
            return (MemberInfo)member.GetValue(configurator);
        }

        public static string GetMemberName(this RepositoryConfigurator configurator)
        {
            return (string)memberName.GetValue(configurator);
        }

        public static string GetName(this RepositoryConfigurator configurator)
        {
            return (string)name.GetValue(configurator);
        }

        static RepositoryConfiguratorExtensions()
        {
            var c = typeof(RepositoryConfigurator);
            member = c.GetField("Member", BindingFlags.Instance | BindingFlags.NonPublic);
            memberName = c.GetField("MemberName", BindingFlags.Instance | BindingFlags.NonPublic);
            name = c.GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic);
        }
    }
}
